﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Files
{
    class Program
    {
        static void Main(string[] args)
        {
            //string newDir = @"D:\Новая папка\Inteducation\yhladkova\20.12_Files\Files\NewDirectory";
            //Directory.CreateDirectory(newDir);

            //string[] files = Directory.GetFiles(@"D:\Новая папка\Inteducation\yhladkova\20.12_Files\Files\Resources", "*.txt", SearchOption.TopDirectoryOnly);

            //if (Directory.Exists(newDir))
            //{
            //    foreach (var file in files)
            //    {
            //        Console.WriteLine(file);
            //        string file2 = file.Replace("Resources", "NewDirectory");
            //        File.Copy(file, file2);
            //    }
            //}

            //bool isDirectoryExists = Directory.Exists(@"D:\Новая папка\Inteducation\yhladkova\20.12_Files\Files\Resources");

            //if (isDirectoryExists)
            //{
            //    Directory.Delete(@"D:\Новая папка\Inteducation\yhladkova\20.12_Files\Files\Resources", true);
            //}

            //string text = "Пыщь!";

            //string[] files2 = Directory.GetFiles(newDir, "*.txt", SearchOption.TopDirectoryOnly);

            //foreach (var file in files2)
            //{
            //    File.WriteAllText(file, text);
            //}


            bool ifFileExists = File.Exists(@"D:\Новая папка\Inteducation\yhladkova\20.12_Files\Files\NewDirectory\Задание.txt");
            string text;
            if (ifFileExists)
            {
                text = File.ReadAllText(@"D:\Новая папка\Inteducation\yhladkova\20.12_Files\Files\NewDirectory\HT.txt");
                text.Replace("\r\n", " ");
                string[] textArray = text.Split(' ');
                int length = Int32.MinValue;
                foreach (var word in textArray)
                {
                    if (word.Length > length)
                    length = word.Length;
                }
                Console.WriteLine("Количество слов - {0}", textArray.GetLength(0));
                Console.WriteLine("Самое длинное слово имеет {0} символов", length);
            }

        }
    }
}
